using System;
using System.Collections;
using System.Data;
using System.Text;
using DAO;
using DTO;

namespace BUS
{
    public class HocSinhBus
    {
        // Them
        public void Them(HocSinhDto hsDto)
        {
            // Kiem tra Business Rule
            if ((hsDto.Toan > 10))
            {
                throw new Exception("Diem toan khong lon hon 10");
            }
            else if ((hsDto.Ly > 10))
            {
                throw new Exception("Diem ly khong lon hon 10");
            }
            else if ((hsDto.Hoa > 10))
            {
                throw new Exception("Diem Hoa khong lon hon 10");
            }
            HocSinhDao hsDao = new HocSinhDao();
            hsDao.Them(hsDto);
        }

        // Xoa
        public void Xoa(int maHocSinh)
        {
            // Kiem tra Business Rule neu co
            HocSinhDao hsDao = new HocSinhDao();
            hsDao.Xoa(maHocSinh);
        }

        // Sua
        public void Sua(HocSinhDto hsDto)
        {
            // Kiem tra Business Rule neu co
            HocSinhDao hsDao = new HocSinhDao();
            hsDao.Sua(hsDto);
        }

        // Tim Kiem
        public HocSinhDto TimKiem(int maHS)
        {
            // Kiem tra Business Rule neu co
            HocSinhDto hsDto;
            HocSinhDao hsDao = new HocSinhDao();
            hsDto = hsDao.TimKiem(maHS);
            return hsDto;
        }

        // Lay Bang
        public DataTable LayBang()
        {
            // Kiem tra Business Rule neu co
            DataTable dt;
            HocSinhDao hsDao = new HocSinhDao();
            dt = hsDao.LayBang();
            return dt;
        }

        // Cap Nhat Bang
        public void CapNhatBang(DataTable dt)
        {
            // Kiem tra Business Rule neu co
            HocSinhDao hsDao = new HocSinhDao();
            hsDao.CapNhatBang(dt);
        }

        // Lay Danh Sach
        public IList LayDanhSach()
        {
            // Kiem tra Business Rule neu co
            IList ds;
            HocSinhDao hsDao = new HocSinhDao();
            ds = hsDao.LayDanhSach();
            return ds;
        }

        public DataTable TimKiem(HocSinhCrt hsCrt)
        {
            DataTable dt;
            HocSinhDao hsDao = new HocSinhDao();
            dt = hsDao.TimKiem(hsCrt);
            return dt;
        }
    }
}
